<?
include engine.'/classes/filesys.class.php';
//die(root);
if ($_POST[node] == 'source') {
	$path = root;
	$curpath = '';
} else {
	$path = root.$_POST[node];
	$curpath = $_POST[node];
}
$dir = filesys::getFolders($path);
if (!empty($dir))
foreach ($dir as $folder) {
	if (!($_POST[node] == 'source' && ($folder=='admin' || $folder=='engine')) && $folder!='template' && $folder!='phpmyadmin' && $folder[0]!='.') { 
		$lines[] = '{"text":"'.$folder.'","id":"'.str_replace('/', '\/', $curpath.'/'.$folder).'","leaf":false, "expandable":true, "singleClickExpand":true, "cls":"folder"}';
	}
}

$files = filesys::getFiles($path);
foreach ($files as $file) {
	$ext = strtolower(strrchr($file, '.'));
	if ($ext == '.php' || $ext == '.php5' || $ext == '.php4' || $ext == '.htm' || $ext == '.html') {
		$lines[] = '{"text":"'.$file.'","id":"'.str_replace('/', '\/', $curpath.'/'.$file).'","leaf":true, "allowChildren":false, "cls":"file"}';
	}
}
echo '['.implode(',', $lines).']';


?>
